home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / JManager.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  27.8 KB  |  687 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        JManager.p
  3.  
  4.      Contains:    Routines that can be used to invoke the Java Virtual Machine in MRJ 
  5.  
  6.      Version:    Technology:    MRJ 2.0
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT JManager;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __JMANAGER__}
  28. {$SETC __JMANAGER__ := 1}
  29.  
  30. {$I+}
  31. {$SETC JManagerIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __CONDITIONALMACROS__}
  35. {$I ConditionalMacros.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MACTYPES__}
  38. {$I MacTypes.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __FILES__}
  41. {$I Files.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __DRAG__}
  44. {$I Drag.p}
  45. {$ENDC}
  46. {$IFC UNDEFINED __QUICKDRAW__}
  47. {$I Quickdraw.p}
  48. {$ENDC}
  49. {$IFC UNDEFINED __MENUS__}
  50. {$I Menus.p}
  51. {$ENDC}
  52. {$IFC UNDEFINED __TEXTCOMMON__}
  53. {$I TextCommon.p}
  54. {$ENDC}
  55.  
  56.  
  57. {$PUSH}
  58. {$ALIGN MAC68K}
  59. {$LibExport+}
  60.  
  61.  
  62.  
  63. CONST
  64.     kJMVersion                    = $11000003;                    {  using Sun's 1.1 APIs, our current APIs.  }
  65.     kDefaultJMTime                = $00000400;                    {  how much time to give the JM library on "empty" events, in milliseconds.  }
  66.  
  67.     kJMVersionError                = -60000;
  68.     kJMExceptionOccurred        = -60001;
  69.     kJMBadClassPathError        = -60002;
  70.  
  71. {
  72.  *    Private data structures
  73.  *
  74.  *    JMClientData        - enough bits to reliably store a pointer to arbitrary, client-specific data. 
  75.  *    JMSessionRef        - references the entire java runtime 
  76.  *    JMTextRef            - a Text string, length, and encoding 
  77.  *    JMTextEncoding        - which encoding to use when converting in and out of Java strings.
  78.  *    JMFrameRef            - a java frame 
  79.  *    JMAWTContextRef     - a context for the AWT to request frames, process events 
  80.  *    JMAppletLocatorRef    - a device for locating, fetching, and parsing URLs that may contain applets 
  81.  *    JMAppletViewerRef    - an object that displays applets in a Frame 
  82.  }
  83.  
  84. TYPE
  85.     JMClientData                        = Ptr;
  86.     JMSessionRef = ^LONGINT;
  87.     JMFrameRef = ^LONGINT;
  88.     JMTextRef = ^LONGINT;
  89.     JMAWTContextRef = ^LONGINT;
  90.     JMAppletLocatorRef = ^LONGINT;
  91.     JMAppletViewerRef = ^LONGINT;
  92.     JMTextEncoding                        = TextEncoding;
  93.  
  94. {
  95.  * The runtime requires certain callbacks be used to communicate between
  96.  * session events and the embedding application.
  97.  *
  98.  * In general, you can pass nil as a callback and a "good" default will be used.
  99.  *
  100.  *    JMConsoleProcPtr          - redirect stderr or stdout - the message is delivered in the encoding specified when
  101.  *                                you created the session, or possibly binary data.
  102.  *    JMConsoleReadProcPtr     - take input from the user from a console or file.  The input is expected to 
  103.  *                                be in the encoding specified when you opened the session.
  104.  *    JMExitProcPtr              - called via System.exit(int), return "true" to kill the current thread,
  105.  *                                false, to cause a 'QUIT' AppleEvent to be sent to the current process,
  106.  *                                or just tear down the runtime and exit to shell immediately
  107.  * JMLowMemoryProcPtr          - This callback is available to notify the embedding application that
  108.  *                                a low memory situation has occurred so it can attempt to recover appropriately.
  109.  * JMAuthenicateURLProcPtr  - prompt the user for autentication based on the URL.  If you pass
  110.  *                                nil, JManager will prompt the user.  Return false if the user pressed cancel.
  111.  }
  112. {$IFC TYPED_FUNCTION_POINTERS}
  113.     JMConsoleProcPtr = PROCEDURE(session: JMSessionRef; message: UNIV Ptr; messageLengthInBytes: UInt32); C;
  114. {$ELSEC}
  115.     JMConsoleProcPtr = ProcPtr;
  116. {$ENDC}
  117.  
  118. {$IFC TYPED_FUNCTION_POINTERS}
  119.     JMConsoleReadProcPtr = FUNCTION(session: JMSessionRef; buffer: UNIV Ptr; maxBufferLength: SInt32): SInt32; C;
  120. {$ELSEC}
  121.     JMConsoleReadProcPtr = ProcPtr;
  122. {$ENDC}
  123.  
  124. {$IFC TYPED_FUNCTION_POINTERS}
  125.     JMExitProcPtr = FUNCTION(session: JMSessionRef; value: LONGINT): BOOLEAN; C;
  126. {$ELSEC}
  127.     JMExitProcPtr = ProcPtr;
  128. {$ENDC}
  129.  
  130. {$IFC TYPED_FUNCTION_POINTERS}
  131.     JMAuthenticateURLProcPtr = FUNCTION(session: JMSessionRef; url: ConstCStringPtr; realm: ConstCStringPtr; VAR userName: CHAR; VAR password: CHAR): BOOLEAN; C;
  132. {$ELSEC}
  133.     JMAuthenticateURLProcPtr = ProcPtr;
  134. {$ENDC}
  135.  
  136. {$IFC TYPED_FUNCTION_POINTERS}
  137.     JMLowMemoryProcPtr = PROCEDURE(session: JMSessionRef); C;
  138. {$ELSEC}
  139.     JMLowMemoryProcPtr = ProcPtr;
  140. {$ENDC}
  141.  
  142.     JMSessionCallbacksPtr = ^JMSessionCallbacks;
  143.     JMSessionCallbacks = RECORD
  144.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  145.         fStandardOutput:        JMConsoleProcPtr;                        {  JM will route "stdout" to this function.  }
  146.         fStandardError:            JMConsoleProcPtr;                        {  JM will route "stderr" to this function.  }
  147.         fStandardIn:            JMConsoleReadProcPtr;                    {  read from console - can be nil for default behavior (no console IO)  }
  148.         fExitProc:                JMExitProcPtr;                            {  handle System.exit(int) requests  }
  149.         fAuthenticateProc:        JMAuthenticateURLProcPtr;                {  present basic authentication dialog  }
  150.         fLowMemProc:            JMLowMemoryProcPtr;                        {  Low Memory notification Proc  }
  151.     END;
  152.  
  153.     JMVerifierOptions             = LONGINT;
  154. CONST
  155.     eDontCheckCode                = {JMVerifierOptions}0;
  156.     eCheckRemoteCode            = {JMVerifierOptions}1;
  157.     eCheckAllCode                = {JMVerifierOptions}2;
  158.  
  159.  
  160. {
  161.  * JMRuntimeOptions is a mask that allows you to specify certain attributes
  162.  * for the runtime. Bitwise or the fields together, or use one of the "premade" entries.
  163.  * eJManager2Defaults is the factory default, and best bet to use.
  164.  }
  165.  
  166. TYPE
  167.     JMRuntimeOptions             = LONGINT;
  168. CONST
  169.     eJManager2Defaults            = {JMRuntimeOptions}0;
  170.     eUseAppHeapOnly                = {JMRuntimeOptions}$01;
  171.     eDisableJITC                = {JMRuntimeOptions}$02;
  172.     eEnableDebugger                = {JMRuntimeOptions}$04;
  173.     eDisableInternetConfig        = {JMRuntimeOptions}$08;
  174.     eInhibitClassUnloading        = {JMRuntimeOptions}$10;
  175.     eEnableProfiling            = {JMRuntimeOptions}$20;
  176.     eJManager1Compatible        = {JMRuntimeOptions}$18;
  177.  
  178.  
  179.  
  180.  
  181. {
  182.  * Returns the version of the currently installed JManager library.
  183.  * Compare to kJMVersion.  This is the only call that doesn't
  184.  * require a session, or a reference to something that references
  185.  * a session.
  186.  }
  187. FUNCTION JMGetVersion: UInt32; C;
  188. {
  189.  * JMOpenSession creates a new Java Runtime.  Note that JManger 2.0 doesn't set 
  190.  * security options at the time of runtime instantiation.  AppletViewer Objecs have
  191.  * seperate security attributes bound to them, and the verifier is availiable elsewhere
  192.  * as well.  The client data parameter lets a client associate an arbitgrary tagged pointer
  193.  * with the seession.
  194.  * When you create the session, you must specify the desired Text Encoding to use for
  195.  * console IO.  Usually, its OK to use "kTextEncodingMacRoman".  See TextCommon.h for the list.
  196.  }
  197. FUNCTION JMOpenSession(VAR session: JMSessionRef; runtimeOptions: JMRuntimeOptions; verifyMode: JMVerifierOptions; {CONST}VAR callbacks: JMSessionCallbacks; desiredEncoding: JMTextEncoding; data: JMClientData): OSStatus; C;
  198. FUNCTION JMCloseSession(session: JMSessionRef): OSStatus; C;
  199.  
  200. {
  201.  * Client data getter/setter functions.
  202.  }
  203. FUNCTION JMGetSessionData(session: JMSessionRef; VAR data: JMClientData): OSStatus; C;
  204. FUNCTION JMSetSessionData(session: JMSessionRef; data: JMClientData): OSStatus; C;
  205.  
  206. {
  207.  * Prepend the target of the FSSpec to the class path.
  208.  * If a file, .zip or other known archive file - not a .class file
  209.  }
  210. FUNCTION JMAddToClassPath(session: JMSessionRef; {CONST}VAR spec: FSSpec): OSStatus; C;
  211.  
  212. {
  213.  * Utility returns (client owned) null terminated handle containing "file://xxxx", or nil if fnfErr
  214.  }
  215. FUNCTION JMFSSToURL(session: JMSessionRef; {CONST}VAR spec: FSSpec): Handle; C;
  216.  
  217. {
  218.  * Turns "file:///disk/file" into an FSSpec.  other handlers return paramErr
  219.  }
  220. FUNCTION JMURLToFSS(session: JMSessionRef; urlString: ConstCStringPtr; VAR spec: FSSpec): OSStatus; C;
  221.  
  222. {
  223.  * JMIdle gives time to all Java threads. Giving more time makes Java programs run faster,
  224.  * but can reduce overall system responsiveness. JMIdle will return sooner if low-level (user)
  225.  * events appear in the event queue.
  226.  }
  227. FUNCTION JMIdle(session: JMSessionRef; jmTimeMillis: UInt32): OSStatus; C;
  228.  
  229. {
  230.  * Java defines system-wide properties that applets can use to make queries about the
  231.  * host system. Many of these properties correspond to defaults provided by "Internet Config."
  232.  * JMPutSessionProperty can be used by a client program to modify various system-wide properties.
  233.  }
  234. FUNCTION JMGetSessionProperty(session: JMSessionRef; propertyName: JMTextRef; VAR propertyValue: JMTextRef): OSStatus; C;
  235. FUNCTION JMPutSessionProperty(session: JMSessionRef; propertyName: JMTextRef; propertyValue: JMTextRef): OSStatus; C;
  236.  
  237. {
  238.  * JMText: opaque object that encapsulates a string, length, and
  239.  * character encoding.  Strings passed between JManager and the
  240.  * embedding application goes through this interface.  Only the most
  241.  * rudimentary conversion routines are supplied - it is expected that
  242.  * the embedding application will most of its work in the System Script.
  243.  *
  244.  * These APIs present some questions about who actually owns the 
  245.  * JMText.  The rule is, if you created a JMTextRef, you are responsible
  246.  * for deleting it after passing it into the runtime.  If the runtime passes
  247.  * one to you, it will be deleted after the callback.
  248.  *
  249.  * If a pointer to an uninitialised JMTextRef is passed in to a routine (eg JMGetSessionProperty),
  250.  * it is assumed to have been created for the caller, and it is the callers responsibility to
  251.  * dispose of it.
  252.  *
  253.  * The encoding types are taken verbatim from the Text Encoding Converter,
  254.  * which handles the ugly backside of script conversion.
  255.  }
  256. {
  257.  * JMNewTextRef can create from a buffer of data in the specified encoding
  258.  }
  259. FUNCTION JMNewTextRef(session: JMSessionRef; VAR textRef: JMTextRef; encoding: JMTextEncoding; charBuffer: UNIV Ptr; bufferLengthInBytes: UInt32): OSStatus; C;
  260.  
  261. {
  262.  * JMCopyTextRef clones a text ref.
  263.  }
  264. FUNCTION JMCopyTextRef(textRefSrc: JMTextRef; VAR textRefDst: JMTextRef): OSStatus; C;
  265.  
  266. {
  267.  * Disposes of a text ref passed back from the runtime, or created explicitly through JMNewTextRef
  268.  }
  269. FUNCTION JMDisposeTextRef(textRef: JMTextRef): OSStatus; C;
  270.  
  271. {
  272.  * Returns the text length, in characters
  273.  }
  274. FUNCTION JMGetTextLength(textRef: JMTextRef; VAR textLengthInCharacters: UInt32): OSStatus; C;
  275.  
  276. {
  277.  * Returns the text length, in number of bytes taken in the destination encoding
  278.  }
  279. FUNCTION JMGetTextLengthInBytes(textRef: JMTextRef; dstEncoding: JMTextEncoding; VAR textLengthInBytes: UInt32): OSStatus; C;
  280.  
  281. {
  282.  * Copies the specified number of characters to the destination buffer with the appropriate
  283.  * destination encoding.
  284.  }
  285. FUNCTION JMGetTextBytes(textRef: JMTextRef; dstEncoding: JMTextEncoding; textBuffer: UNIV Ptr; textBufferLength: UInt32; VAR numCharsCopied: UInt32): OSStatus; C;
  286.  
  287. {
  288.  * Returns a Handle to a null terminated, "C" string in the System Script.
  289.  }
  290. FUNCTION JMTextToMacOSCStringHandle(textRef: JMTextRef): Handle; C;
  291.  
  292.  
  293.  
  294. {
  295.  * Proxy properties in the runtime.
  296.  *
  297.  * These will only be checked if InternetConfig isn't used to specify properties,
  298.  * or if it doesn't have the data for these.
  299.  }
  300.  
  301. TYPE
  302.     JMProxyInfoPtr = ^JMProxyInfo;
  303.     JMProxyInfo = RECORD
  304.         useProxy:                BOOLEAN;
  305.         proxyHost:                PACKED ARRAY [0..254] OF CHAR;
  306.         proxyPort:                UInt16;
  307.     END;
  308.  
  309.     JMProxyType                 = LONGINT;
  310. CONST
  311.     eHTTPProxy                    = {JMProxyType}0;
  312.     eFirewallProxy                = {JMProxyType}1;
  313.     eFTPProxy                    = {JMProxyType}2;
  314.  
  315. FUNCTION JMGetProxyInfo(session: JMSessionRef; proxyType: JMProxyType; VAR proxyInfo: JMProxyInfo): OSStatus; C;
  316. FUNCTION JMSetProxyInfo(session: JMSessionRef; proxyType: JMProxyType; {CONST}VAR proxyInfo: JMProxyInfo): OSStatus; C;
  317.  
  318. {
  319.  * Security - JManager 2.0 security is handled on a per-applet basis.
  320.  * There are some security settings that are inherited from InternetConfig
  321.  * (Proxy Servers) but the verifier can now be enabled and disabled.
  322.  }
  323. FUNCTION JMGetVerifyMode(session: JMSessionRef; VAR verifierOptions: JMVerifierOptions): OSStatus; C;
  324. FUNCTION JMSetVerifyMode(session: JMSessionRef; verifierOptions: JMVerifierOptions): OSStatus; C;
  325.  
  326.  
  327.  
  328. {
  329.  * The basic unit of AWT interaction is the JMFrame.  A JMFrame is bound to top level
  330.  * awt Frame, Window, or Dialog.  When a user event occurs for a MacOS window, the event is passed
  331.  * to the corrosponding frame object.  Similarly, when an AWT event occurs that requires the
  332.  * Mac OS Window to change, a callback is made.  JManager 1.x bound the frame to the window through
  333.  * a callback to set and restore the windows GrafPort.  In JManager 2.0, a GrafPort, Offset, and 
  334.  * ClipRgn are specified up front - changes in visibility and structure require that these be re-set.
  335.  * This enables support for the JavaSoft DrawingSurface API - and also improves graphics performance.
  336.  * You should reset the graphics attributes anytime the visiblity changes, like when scrolling.
  337.  * You should also set it initially when the AWTContext requests the frame.
  338.  * At various times, JM will call back to the client to register a new JMFrame, 
  339.  * indicating the frame type.  The client should take the following steps:
  340.  *
  341.  *    o    Create a new invisible window of the specified type
  342.  *    o    Fill in the callbacks parameter with function pointers
  343.  *    o    Do something to bind the frame to the window (like stuff the WindowPtr in the JMClientData of the frame)
  344.  *    o    Register the visiblity parameters (GrafPtr, etc) with the frame
  345.  }
  346.  
  347. TYPE
  348.     ReorderRequest                 = LONGINT;
  349. CONST
  350.     eBringToFront                = {ReorderRequest}0;            {  bring the window to front  }
  351.     eSendToBack                    = {ReorderRequest}1;            {  send the window to back  }
  352.     eSendBehindFront            = {ReorderRequest}2;            {  send the window behind the front window  }
  353.  
  354.  
  355. TYPE
  356. {$IFC TYPED_FUNCTION_POINTERS}
  357.     JMSetFrameSizeProcPtr = PROCEDURE(frame: JMFrameRef; {CONST}VAR newBounds: Rect); C;
  358. {$ELSEC}
  359.     JMSetFrameSizeProcPtr = ProcPtr;
  360. {$ENDC}
  361.  
  362. {$IFC TYPED_FUNCTION_POINTERS}
  363.     JMFrameInvalRectProcPtr = PROCEDURE(frame: JMFrameRef; {CONST}VAR r: Rect); C;
  364. {$ELSEC}
  365.     JMFrameInvalRectProcPtr = ProcPtr;
  366. {$ENDC}
  367.  
  368. {$IFC TYPED_FUNCTION_POINTERS}
  369.     JMFrameShowHideProcPtr = PROCEDURE(frame: JMFrameRef; showFrameRequested: BOOLEAN); C;
  370. {$ELSEC}
  371.     JMFrameShowHideProcPtr = ProcPtr;
  372. {$ENDC}
  373.  
  374. {$IFC TYPED_FUNCTION_POINTERS}
  375.     JMSetTitleProcPtr = PROCEDURE(frame: JMFrameRef; title: JMTextRef); C;
  376. {$ELSEC}
  377.     JMSetTitleProcPtr = ProcPtr;
  378. {$ENDC}
  379.  
  380. {$IFC TYPED_FUNCTION_POINTERS}
  381.     JMCheckUpdateProcPtr = PROCEDURE(frame: JMFrameRef); C;
  382. {$ELSEC}
  383.     JMCheckUpdateProcPtr = ProcPtr;
  384. {$ENDC}
  385.  
  386. {$IFC TYPED_FUNCTION_POINTERS}
  387.     JMReorderFrame = PROCEDURE(frame: JMFrameRef; theRequest: ReorderRequest); C;
  388. {$ELSEC}
  389.     JMReorderFrame = ProcPtr;
  390. {$ENDC}
  391.  
  392. {$IFC TYPED_FUNCTION_POINTERS}
  393.     JMSetResizeable = PROCEDURE(frame: JMFrameRef; resizeable: BOOLEAN); C;
  394. {$ELSEC}
  395.     JMSetResizeable = ProcPtr;
  396. {$ENDC}
  397.  
  398.     JMFrameCallbacksPtr = ^JMFrameCallbacks;
  399.     JMFrameCallbacks = RECORD
  400.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  401.         fSetFrameSize:            JMSetFrameSizeProcPtr;
  402.         fInvalRect:                JMFrameInvalRectProcPtr;
  403.         fShowHide:                JMFrameShowHideProcPtr;
  404.         fSetTitle:                JMSetTitleProcPtr;
  405.         fCheckUpdate:            JMCheckUpdateProcPtr;
  406.         fReorderFrame:            JMReorderFrame;
  407.         fSetResizeable:            JMSetResizeable;
  408.     END;
  409.  
  410. FUNCTION JMSetFrameVisibility(frame: JMFrameRef; famePort: GrafPtr; frameOrigin: Point; frameClip: RgnHandle): OSStatus; C;
  411. FUNCTION JMGetFrameData(frame: JMFrameRef; VAR data: JMClientData): OSStatus; C;
  412. FUNCTION JMSetFrameData(frame: JMFrameRef; data: JMClientData): OSStatus; C;
  413. FUNCTION JMGetFrameSize(frame: JMFrameRef; VAR result: Rect): OSStatus; C;
  414. { note that the top left indicates the "global" position of this frame }
  415. { use this to update the frame position when it gets moved }
  416. FUNCTION JMSetFrameSize(frame: JMFrameRef; {CONST}VAR newSize: Rect): OSStatus; C;
  417. {
  418.  * Dispatch a particular event to an embedded frame
  419.  }
  420. FUNCTION JMFrameClick(frame: JMFrameRef; localPos: Point; modifiers: INTEGER): OSStatus; C;
  421. FUNCTION JMFrameKey(frame: JMFrameRef; asciiChar: ByteParameter; keyCode: ByteParameter; modifiers: INTEGER): OSStatus; C;
  422. FUNCTION JMFrameKeyRelease(frame: JMFrameRef; asciiChar: ByteParameter; keyCode: ByteParameter; modifiers: INTEGER): OSStatus; C;
  423. FUNCTION JMFrameUpdate(frame: JMFrameRef; updateRgn: RgnHandle): OSStatus; C;
  424. FUNCTION JMFrameActivate(frame: JMFrameRef; activate: BOOLEAN): OSStatus; C;
  425. FUNCTION JMFrameResume(frame: JMFrameRef; resume: BOOLEAN): OSStatus; C;
  426. FUNCTION JMFrameMouseOver(frame: JMFrameRef; localPos: Point; modifiers: INTEGER): OSStatus; C;
  427. FUNCTION JMFrameShowHide(frame: JMFrameRef; showFrame: BOOLEAN): OSStatus; C;
  428. FUNCTION JMFrameGoAway(frame: JMFrameRef): OSStatus; C;
  429. FUNCTION JMGetFrameContext(frame: JMFrameRef): JMAWTContextRef; C;
  430. FUNCTION JMFrameDragTracking(frame: JMFrameRef; message: DragTrackingMessage; theDragRef: DragReference): OSStatus; C;
  431. FUNCTION JMFrameDragReceive(frame: JMFrameRef; theDragRef: DragReference): OSStatus; C;
  432. {
  433.  * Window types
  434.  }
  435.  
  436. TYPE
  437.     JMFrameKind                 = LONGINT;
  438. CONST
  439.     eBorderlessModelessWindowFrame = {JMFrameKind}0;
  440.     eModelessWindowFrame        = {JMFrameKind}1;
  441.     eModalWindowFrame            = {JMFrameKind}2;
  442.     eModelessDialogFrame        = {JMFrameKind}3;
  443.  
  444.  
  445.  
  446.  
  447. { JMAWTContext -
  448.  * To create a top level frame, you must use a JMAWTContext object.
  449.  * The JMAWTContext provides a context for the AWT to request frames.
  450.  * A AWTContext has a threadgroup associated with it - all events and processing occurs
  451.  * there.  When you create one, it is quiescent, you must call resume before it begins executing.
  452.  }
  453.  
  454. TYPE
  455. {$IFC TYPED_FUNCTION_POINTERS}
  456.     JMRequestFrameProcPtr = FUNCTION(context: JMAWTContextRef; newFrame: JMFrameRef; kind: JMFrameKind; {CONST}VAR initialBounds: Rect; resizeable: BOOLEAN; VAR callbacks: JMFrameCallbacks): OSStatus; C;
  457. {$ELSEC}
  458.     JMRequestFrameProcPtr = ProcPtr;
  459. {$ENDC}
  460.  
  461. {$IFC TYPED_FUNCTION_POINTERS}
  462.     JMReleaseFrameProcPtr = FUNCTION(context: JMAWTContextRef; oldFrame: JMFrameRef): OSStatus; C;
  463. {$ELSEC}
  464.     JMReleaseFrameProcPtr = ProcPtr;
  465. {$ENDC}
  466.  
  467. {$IFC TYPED_FUNCTION_POINTERS}
  468.     JMUniqueMenuIDProcPtr = FUNCTION(context: JMAWTContextRef; isSubmenu: BOOLEAN): SInt16; C;
  469. {$ELSEC}
  470.     JMUniqueMenuIDProcPtr = ProcPtr;
  471. {$ENDC}
  472.  
  473. {$IFC TYPED_FUNCTION_POINTERS}
  474.     JMExceptionOccurredProcPtr = PROCEDURE(context: JMAWTContextRef; exceptionName: JMTextRef; exceptionMsg: JMTextRef; stackTrace: JMTextRef); C;
  475. {$ELSEC}
  476.     JMExceptionOccurredProcPtr = ProcPtr;
  477. {$ENDC}
  478.  
  479.     JMAWTContextCallbacksPtr = ^JMAWTContextCallbacks;
  480.     JMAWTContextCallbacks = RECORD
  481.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  482.         fRequestFrame:            JMRequestFrameProcPtr;                    {  a new frame is being created.  }
  483.         fReleaseFrame:            JMReleaseFrameProcPtr;                    {  an existing frame is being destroyed.  }
  484.         fUniqueMenuID:            JMUniqueMenuIDProcPtr;                    {  a new menu will be created with this id.  }
  485.         fExceptionOccurred:        JMExceptionOccurredProcPtr;                {  just some notification that some recent operation caused an exception.  You can't do anything really from here.  }
  486.     END;
  487.  
  488. FUNCTION JMNewAWTContext(VAR context: JMAWTContextRef; session: JMSessionRef; {CONST}VAR callbacks: JMAWTContextCallbacks; data: JMClientData): OSStatus; C;
  489. FUNCTION JMDisposeAWTContext(context: JMAWTContextRef): OSStatus; C;
  490. FUNCTION JMGetAWTContextData(context: JMAWTContextRef; VAR data: JMClientData): OSStatus; C;
  491. FUNCTION JMSetAWTContextData(context: JMAWTContextRef; data: JMClientData): OSStatus; C;
  492. FUNCTION JMCountAWTContextFrames(context: JMAWTContextRef; VAR frameCount: UInt32): OSStatus; C;
  493. FUNCTION JMGetAWTContextFrame(context: JMAWTContextRef; frameIndex: UInt32; VAR frame: JMFrameRef): OSStatus; C;
  494. FUNCTION JMMenuSelected(context: JMAWTContextRef; hMenu: MenuHandle; menuItem: INTEGER): OSStatus; C;
  495.  
  496.  
  497.  
  498. {*
  499.  * JMAppletLocator - Since Java applets are always referenced by a Uniform Resource Locator
  500.  * (see RFC 1737, http://www.w3.org/pub/WWW/Addressing/rfc1738.txt), we provide an object
  501.  * that encapsulates the information about a set of applets. A JMAppletLocator is built
  502.  * by providing a base URL, which must point at a valid HTML document containing applet
  503.  * tags. To save a network transaction, the contents of the document may be passed optionally. 
  504.  *
  505.  * You can also use a JMLocatorInfoBlock for a synchronous resolution of the applet,
  506.  * assuming that you already have the info for the tag.
  507.  }
  508.  
  509. TYPE
  510.     JMLocatorErrors             = LONGINT;
  511. CONST
  512.     eLocatorNoErr                = {JMLocatorErrors}0;            {  the html was retrieved successfully }
  513.     eHostNotFound                = {JMLocatorErrors}1;            {  the host specified by the url could not be found }
  514.     eFileNotFound                = {JMLocatorErrors}2;            {  the file could not be found on the host }
  515.     eLocatorTimeout                = {JMLocatorErrors}3;            {  a timeout occurred retrieving the html text }
  516.     eLocatorKilled                = {JMLocatorErrors}4;            {  in response to a JMDisposeAppletLocator before it has completed }
  517.  
  518.  
  519. TYPE
  520. {$IFC TYPED_FUNCTION_POINTERS}
  521.     JMFetchCompleted = PROCEDURE(ref: JMAppletLocatorRef; status: JMLocatorErrors); C;
  522. {$ELSEC}
  523.     JMFetchCompleted = ProcPtr;
  524. {$ENDC}
  525.  
  526.     JMAppletLocatorCallbacksPtr = ^JMAppletLocatorCallbacks;
  527.     JMAppletLocatorCallbacks = RECORD
  528.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  529.         fCompleted:                JMFetchCompleted;                        {  called when the html has been completely fetched  }
  530.     END;
  531.  
  532. {
  533.  * These structures are used to pass pre-parsed parameter
  534.  * tags to the AppletLocator.  Implies synchronous semantics.
  535.  }
  536.  
  537.     JMLIBOptionalParamsPtr = ^JMLIBOptionalParams;
  538.     JMLIBOptionalParams = RECORD
  539.         fParamName:                JMTextRef;                                {  could be from a <parameter name=foo value=bar> or "zipbase", etc  }
  540.         fParamValue:            JMTextRef;                                {  the value of this optional tag  }
  541.     END;
  542.  
  543.     JMLocatorInfoBlockPtr = ^JMLocatorInfoBlock;
  544.     JMLocatorInfoBlock = RECORD
  545.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  546.                                                                         {  These are required to be present and not nil  }
  547.         fBaseURL:                JMTextRef;                                {  the URL of this applet's host page  }
  548.         fAppletCode:            JMTextRef;                                {  code= parameter  }
  549.         fWidth:                    INTEGER;                                {  width= parameter  }
  550.         fHeight:                INTEGER;                                {  height= parameter  }
  551.                                                                         {  These are optional parameters  }
  552.         fOptionalParameterCount: LONGINT;                                {  how many in this array  }
  553.         fParams:                JMLIBOptionalParamsPtr;                    {  pointer to an array of these (points to first element)  }
  554.     END;
  555.  
  556. FUNCTION JMNewAppletLocator(VAR locatorRef: JMAppletLocatorRef; session: JMSessionRef; {CONST}VAR callbacks: JMAppletLocatorCallbacks; url: JMTextRef; htmlText: JMTextRef; data: JMClientData): OSStatus; C;
  557. FUNCTION JMNewAppletLocatorFromInfo(VAR locatorRef: JMAppletLocatorRef; session: JMSessionRef; {CONST}VAR info: JMLocatorInfoBlock; data: JMClientData): OSStatus; C;
  558. FUNCTION JMDisposeAppletLocator(locatorRef: JMAppletLocatorRef): OSStatus; C;
  559. FUNCTION JMGetAppletLocatorData(locatorRef: JMAppletLocatorRef; VAR data: JMClientData): OSStatus; C;
  560. FUNCTION JMSetAppletLocatorData(locatorRef: JMAppletLocatorRef; data: JMClientData): OSStatus; C;
  561. FUNCTION JMCountApplets(locatorRef: JMAppletLocatorRef; VAR appletCount: UInt32): OSStatus; C;
  562. FUNCTION JMGetAppletDimensions(locatorRef: JMAppletLocatorRef; appletIndex: UInt32; VAR width: UInt32; VAR height: UInt32): OSStatus; C;
  563. FUNCTION JMGetAppletTag(locatorRef: JMAppletLocatorRef; appletIndex: UInt32; VAR tagRef: JMTextRef): OSStatus; C;
  564. FUNCTION JMGetAppletName(locatorRef: JMAppletLocatorRef; appletIndex: UInt32; VAR nameRef: JMTextRef): OSStatus; C;
  565.  
  566. {
  567.  * JMAppletViewer - Applets are instantiated, one by one, by specifying a JMAppletLocator and
  568.  * a zero-based index (Macintosh API's usually use one-based indexing, the Java language
  569.  * uses zero, however.). The resulting applet is encapsulated in a JMAppletViewer object. 
  570.  * Since applets can have one or more visible areas to draw in, one or more JMFrame objects
  571.  * may be requested while the viewer is being created, or at a later time, thus the client
  572.  * must provide callbacks to satisfy these requests.
  573.  *
  574.  * The window name for the ShowDocument callback is one of:
  575.  *   _self        show in current frame
  576.  *   _parent    show in parent frame
  577.  *   _top        show in top-most frame
  578.  *   _blank        show in new unnamed top-level window
  579.  *   <other>    show in new top-level window named <other> 
  580.  }
  581.  
  582. TYPE
  583. {$IFC TYPED_FUNCTION_POINTERS}
  584.     JMShowDocumentProcPtr = PROCEDURE(viewer: JMAppletViewerRef; urlString: JMTextRef; windowName: JMTextRef); C;
  585. {$ELSEC}
  586.     JMShowDocumentProcPtr = ProcPtr;
  587. {$ENDC}
  588.  
  589. {$IFC TYPED_FUNCTION_POINTERS}
  590.     JMSetStatusMsgProcPtr = PROCEDURE(viewer: JMAppletViewerRef; statusMsg: JMTextRef); C;
  591. {$ELSEC}
  592.     JMSetStatusMsgProcPtr = ProcPtr;
  593. {$ENDC}
  594.  
  595.     JMAppletViewerCallbacksPtr = ^JMAppletViewerCallbacks;
  596.     JMAppletViewerCallbacks = RECORD
  597.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  598.         fShowDocument:            JMShowDocumentProcPtr;                    {  go to a url, optionally in a new window  }
  599.         fSetStatusMsg:            JMSetStatusMsgProcPtr;                    {  applet changed status message  }
  600.     END;
  601.  
  602. {
  603.  * NEW: per-applet security settings
  604.  * Previously, these settings were attached to the session.
  605.  * JManager 2.0 allows them to be attached to each viewer.
  606.  }
  607.     JMNetworkSecurityOptions     = LONGINT;
  608. CONST
  609.     eNoNetworkAccess            = {JMNetworkSecurityOptions}0;
  610.     eAppletHostAccess            = {JMNetworkSecurityOptions}1;
  611.     eUnrestrictedAccess            = {JMNetworkSecurityOptions}2;
  612.  
  613.  
  614. TYPE
  615.     JMFileSystemOptions         = LONGINT;
  616. CONST
  617.     eNoFSAccess                    = {JMFileSystemOptions}0;
  618.     eLocalAppletAccess            = {JMFileSystemOptions}1;
  619.     eAllFSAccess                = {JMFileSystemOptions}2;
  620.  
  621. {
  622.  * Lists of packages are comma separated,
  623.  * the default for mrj.security.system.access is
  624.  * "sun,netscape,com.apple".
  625.  }
  626.  
  627.  
  628. TYPE
  629.     JMAppletSecurityPtr = ^JMAppletSecurity;
  630.     JMAppletSecurity = RECORD
  631.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  632.         fNetworkSecurity:        JMNetworkSecurityOptions;                {  can this applet access network resources  }
  633.         fFileSystemSecurity:    JMFileSystemOptions;                    {  can this applet access network resources  }
  634.         fRestrictSystemAccess:    BOOLEAN;                                {  restrict access to system packages (com.apple.*, sun.*, netscape.*) also found in the property "mrj.security.system.access"  }
  635.         fRestrictSystemDefine:    BOOLEAN;                                {  restrict classes from loading system packages (com.apple.*, sun.*, netscape.*) also found in the property "mrj.security.system.define"  }
  636.         fRestrictApplicationAccess: BOOLEAN;                            {  restrict access to application packages found in the property "mrj.security.application.access"  }
  637.         fRestrictApplicationDefine: BOOLEAN;                            {  restrict access to application packages found in the property "mrj.security.application.access"  }
  638.     END;
  639.  
  640. {
  641.  * AppletViewer methods
  642.  }
  643. FUNCTION JMNewAppletViewer(VAR viewer: JMAppletViewerRef; context: JMAWTContextRef; locatorRef: JMAppletLocatorRef; appletIndex: UInt32; {CONST}VAR security: JMAppletSecurity; {CONST}VAR callbacks: JMAppletViewerCallbacks; data: JMClientData): OSStatus; C;
  644. FUNCTION JMDisposeAppletViewer(viewer: JMAppletViewerRef): OSStatus; C;
  645. FUNCTION JMGetAppletViewerData(viewer: JMAppletViewerRef; VAR data: JMClientData): OSStatus; C;
  646. FUNCTION JMSetAppletViewerData(viewer: JMAppletViewerRef; data: JMClientData): OSStatus; C;
  647.  
  648. {
  649.  * You can change the applet security on the fly
  650.  }
  651. FUNCTION JMGetAppletViewerSecurity(viewer: JMAppletViewerRef; VAR data: JMAppletSecurity): OSStatus; C;
  652. FUNCTION JMSetAppletViewerSecurity(viewer: JMAppletViewerRef; {CONST}VAR data: JMAppletSecurity): OSStatus; C;
  653.  
  654. {
  655.  * JMReloadApplet reloads viewer's applet from the source.
  656.  * JMRestartApplet reinstantiates the applet without reloading.
  657.  }
  658. FUNCTION JMReloadApplet(viewer: JMAppletViewerRef): OSStatus; C;
  659. FUNCTION JMRestartApplet(viewer: JMAppletViewerRef): OSStatus; C;
  660.  
  661. {
  662.  * JMSuspendApplet tells the Java thread scheduler to stop executing the viewer's applet.
  663.  * JMResumeApplet resumes execution of the viewer's applet.
  664.  }
  665. FUNCTION JMSuspendApplet(viewer: JMAppletViewerRef): OSStatus; C;
  666. FUNCTION JMResumeApplet(viewer: JMAppletViewerRef): OSStatus; C;
  667.  
  668.  * To get back to the JMAppletViewerRef instance from whence a frame came,
  669.  * as well as the ultimate frame parent (the one created _for_ the applet viewer)
  670.  }
  671. FUNCTION JMGetFrameViewer(frame: JMFrameRef; VAR viewer: JMAppletViewerRef; VAR parentFrame: JMFrameRef): OSStatus; C;
  672. {
  673.  * To get a ref back to the Frame that was created for this JMAppletViewerRef
  674.  }
  675. FUNCTION JMGetViewerFrame(viewer: JMAppletViewerRef; VAR frame: JMFrameRef): OSStatus; C;
  676. {$ALIGN RESET}
  677. {$POP}
  678.  
  679. {$SETC UsingIncludes := JManagerIncludes}
  680.  
  681. {$ENDC} {__JMANAGER__}
  682.  
  683. {$IFC NOT UsingIncludes}
  684.  END.
  685. {$ENDC}
  686.